package com.xiaochong.tir.manager.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaochong.tir.common.data.mapper.CurrencyInfoMapper;
import com.xiaochong.tir.common.data.po.ConceptCategory;
import com.xiaochong.tir.common.data.po.CurrencyIndustryCategory;
import com.xiaochong.tir.common.data.vo.BasePeriodHistoryVo;
import com.xiaochong.tir.common.data.vo.CurrencyList;
import com.xiaochong.tir.common.data.vo.CurrencyTraVo;
import com.xiaochong.tir.manager.config.druid.Operation;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
import com.xiaochong.tir.common.data.po.CurrencyInfo;
import org.springframework.transaction.annotation.Transactional;

/**
 * 此类为[基础代码]自动生成,已经拥有基本的增删改成操作 
 * <其他请自行扩展>
 * @author cx
 * @time 2018-04-26 17:32
 * 
 */
@Service
public class CurrencyInfoService{
 
      
    @Autowired
	private CurrencyInfoMapper currencyInfoDao;
	
	
	/**
     * 新增
     * @param entity 
     * @param session
     */
	@Operation
	@Transactional
    public int insertSelective (CurrencyInfo entity) { 
     return this.currencyInfoDao.insertSelective(entity);
    }	
    
    /**
     * 批量新增
     * @param list 
     * @param session
     */
    public void insertBatch(List<CurrencyInfo> list) {
           
          this.currencyInfoDao.insertBatch(list);
         
         
    }
    
    /**
     * 根据主键修改单条数据
     * @param entity 
     * @param session
     */
    @Operation
    @Transactional
    public int updateByPrimaryKey(CurrencyInfo entity,CurrencyInfo currencyInfo) {
           return this.currencyInfoDao.updateByPrimaryKey(entity);
    }
    
    /**
     * 根据主键批量修改数据
     * @param list 
     * @param session
     */
    public void updateBatch(List<CurrencyInfo> list) {
           
          this.currencyInfoDao.updateBatch(list);
          
        
    }
    
    /**
     * 根据主键查询单条数据
     * @param id
     */
    public CurrencyInfo selectByPrimaryKey(Integer id) {
            return this.currencyInfoDao.selectByPrimaryKey(id);
    }
    
    /**
     * 根据条件查询单条记录
     * @param entity 
     */
    public CurrencyInfo selectByEntity(CurrencyInfo entity) {
           return this.currencyInfoDao.selectByEntity(entity);
    }
    
    
    /**
     * 根据条件查询多条记录
     * @param entity 
     */
    public List<CurrencyInfo> selectByEntityList(CurrencyInfo entity) {
           return  this.currencyInfoDao.selectByEntityList(entity);
    }
    
    /**
     * 根据条件查询Id
     * @param entity 
     */
    public Integer selectById(CurrencyInfo entity) {
           return  this.currencyInfoDao.selectById(entity);
    }
    
     /**
     * 根据条件查询Ids
     * @param entity 
     */
    public List<Integer> selectByIds(CurrencyInfo entity) {
        return  this.currencyInfoDao.selectByIds(entity);
    }
    
     /**
     * 根据主键删除单条记录
     * @param id
     */
     @Transactional
    public void deleteByPrimaryKey(Integer id) {
           this.currencyInfoDao.deleteByPrimaryKey(id);
    }
    
    /**
     * 根据主键删除多条记录
     * @param list
     */
    public void deleteBatch(List<Integer> list) {
           this.currencyInfoDao.deleteBatch(list);
    }
    
     /**
     * 根据某些条件删除
     * @param entity
     */
    public void deleteBatch(CurrencyInfo entity) {
           this.currencyInfoDao.deleteByEntity(entity);
    }


    public PageInfo<CurrencyList> serchByCurrencyList(CurrencyList currencyList) {
        PageHelper.startPage(currencyList.getPageIndex(), currencyList.getPageSize());
       return new PageInfo<CurrencyList>(this.currencyInfoDao.serchByEntity(currencyList));
    }

    public List<CurrencyList> SerchConcept(Integer id) {
        return this.currencyInfoDao.SerchConcept(id);
    }

    public List<CurrencyIndustryCategory> industryList() {
        return this.currencyInfoDao.industryList();
    }

    public List<ConceptCategory> conceptCategoryList() {
        return this.currencyInfoDao.conceptCategoryList();
    }

	public PageInfo<CurrencyInfo> listCurrency(CurrencyInfo currencyInfo, Integer page, Integer limit) {
		PageHelper.startPage(page, limit);
	    return new PageInfo<CurrencyInfo>(this.currencyInfoDao.listCurrency(currencyInfo));
	}

    public List<CurrencyTraVo> selectCurrencyTraList(Integer currencyId) {
        return this.currencyInfoDao.selectCurrencyTraList(currencyId);
    }

    public int updateCurrencyTra(Integer currencyId) {
        return this.currencyInfoDao.updateCurrencyTra(currencyId);
    }

    public PageInfo<CurrencyTraVo> selExchangeTraList(CurrencyTraVo cv, Integer pageSize, Integer pageIndex) {
        PageHelper.startPage(pageIndex, pageSize);
        return new PageInfo<CurrencyTraVo>(this.currencyInfoDao.selExchangeTraList(cv));
    }

    @Operation
    @Transactional
    public int editByPrimaryKey(CurrencyInfo currencyInfo, CurrencyInfo info) {
        return this.currencyInfoDao.updateByPrimaryKey(currencyInfo);
    }

    public List<CurrencyTraVo> selCurTraList(Integer id) {
        return this.currencyInfoDao.selCurTraList(id);
    }

    public PageInfo<CurrencyTraVo> selAppExTra(CurrencyTraVo cv, Integer pageSize, Integer pageIndex) {
        PageHelper.startPage(pageIndex,pageSize);
        PageInfo<CurrencyTraVo> info = new PageInfo<>(this.currencyInfoDao.selAppExTra(cv));
        return info;
    }

    public List<BasePeriodHistoryVo> selectByHistoryList() {
        return this.currencyInfoDao.selectByHistoryList();
    }
}